/*
 * This file is part of Super Luigi Bros.
 * Super Luigi Bros is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Super Luigi Bros is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Super Luigi Bros.  If not, see <http://www.gnu.org/licenses/>.
 */
package luigibros.displayComponents;

import java.awt.Image;
import java.awt.image.ImageObserver;
import java.util.Map;
import java.awt.Rectangle;


/** This class renders and scales the images, manages the
 *  cache and draws them to buffers,which will be painted by
 *  DisplayComponent
 *  @author - bshudi@gmail.com
 */
public class Renderer
{
	private ImageObserver observer;
	private Image bgOrig;
	private Image bgScale;
	
	/** This constructor takes a parameter of ImageObserver and
	 *  should set a value for the observer
	 *  @param observer
	 *  @author bshudi@gmail.com
	 */
	public Renderer (ImageObserver observer)
	{}
	
	/** This method sets the background image to the window
	 *  used for Super Luigi Bros
	 *  @param backGround
	 *  @author bshudi@gmail.com
	 */
	public void setBackground(Image backGround)
	{
		bgScale = bgOrig = backGround;
		
	}
	
	/** This method gets uses the width and height as
	 *  parameters and then scales the background images based 
	 *  upon the width and height sent to the method
	 *  @param width
	 *  @param height
	 */
	public void setSize(int width, int height)
	{
		if (bgScale.getHeight(observer) != height || bgScale.getWidth(observer) != width)
		{
			bgScale = bgOrig.getScaledInstance(width, height, Image.SCALE_SMOOTH);
		}
	}
}
